<!DOCTYPE html>
<html lang="en">
	<head>
		<title>Unicorn Admin</title>
		<meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="stylesheet" href="/static/css/bootstrap.min.css" />
		<link rel="stylesheet" href="/static/css/bootstrap-responsive.min.css" />
		<link rel="stylesheet" href="/static/css/uniform.css" />
		<link rel="stylesheet" href="/static/css/select2.css" />
		<link rel="stylesheet" href="/static/css/datepicker.css" />		
		<link rel="stylesheet" href="/static/css/unicorn.main.css" />
		<link rel="stylesheet" href="/static/css/unicorn.grey.css" class="skin-color" />	
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<script type="text/javascript" src="/static/js/jquery.min.js"></script>
		<script type="text/javascript" src="/static/cityJSON.txt"></script>
		<script type="text/javascript">
        	$(document).ready(function() {
        		if('${contact}'==''){
    				$("#orgH1").html('添加联系人');
    				$("#submitbt").attr('disabled', true);
    			}else{
    				$("#orgH1").html('修改联系人');
    				$('#nameSpan').html('');
					$('#jobSpan').html('');
					$('#telSpan').html('');
					$('#phoneSpan').html('');
					$('#emailSpan').html('');
    			}
        		if('${contact.sex}'=='女'){
        			$("#girl").attr("checked","true");
        		}else{
        			$("#boy").attr("checked","true");
        		}
			    $("[name='important']").val('${contact.important}');
			    $("[name='operatorName']").val('${contact.operatorName}');
			    $("[name='infoSource']").val('${contact.infoSource}');
			    $("[name='remark']").val('${contact.remark}');
			    
        		$("[name='name']").blur(function(){
        			if($(this).val()==''){
        				$("#nameSpan").html("联系人名称不能为空");
        				$("#nameSpan").css('color','red');
        			}else{
        				$("#nameSpan").html("");
        			}
            	});
        		$("[name='job']").blur(function(){
        			if($(this).val()==''){
        				$("#jobSpan").html("职务不能为空");
        				$("#jobSpan").css('color','red');
        			}else{
        				$("#jobSpan").html("");
        			}
            	});
        		$("[name='phone']").blur(function(){
        			if($(this).val()==''){
        				$("#phoneSpan").html("手机不能为空");
        				$("#phoneSpan").css('color','red');
        			}else{
        				$("#phoneSpan").html("");
        			}
            	});
        		$("[name='tel']").blur(function(){
        			if($(this).val()==''){
        				$("#telSpan").html("电话不能为空");
        				$("#telSpan").css('color','red');
        			}else{
        				$("#telSpan").html("");
        			}
            	});
        		$("[name='email']").blur(function(){
        			if($(this).val()==''){
        				$("#emailSpan").html("邮箱不能为空");
        				$("#emailSpan").css('color','red');
        			}else{
        				$("#emailSpan").html("");
        			}
            	});
        		$(".redStar").change(function(){
        			$("#submitbt").attr('disabled',false);
        			$(".redStar").each(function(){
        				if($(this).val()==""){
        					$("#submitbt").attr('disabled',true);
        				}
        			});
        		});
        		$("#submitbt").click(function(){
        			if('${contact}'==''){
        				if(confirm("确认添加？'${contact}'")){
        					$("#basic_validate").attr("action","addContactAction");
        					$("#basic_validate").submit();
        				}
        			}else{
        				if(confirm("确认修改？")){
        					$("#basic_validate").attr("action","updateContactAction");
        					$("#basic_validate").submit();
        				}
        			}
        		});
        	});
        	
        </script>
	</head>
	<body>
		<#include "menu.ftl">
		<div id="content">
			<div id="content-header">
				<h1 id="orgH1">添加联系人</h1>
				<div class="btn-group">
					<a class="btn btn-large tip-bottom" title="Manage Files"><i class="icon-file"></i></a>
					<a class="btn btn-large tip-bottom" title="Manage Users"><i class="icon-user"></i></a>
					<a class="btn btn-large tip-bottom" title="Manage Comments"><i class="icon-comment"></i><span class="label label-important">5</span></a>
					<a class="btn btn-large tip-bottom" title="Manage Orders"><i class="icon-shopping-cart"></i></a>
				</div>
			</div>
			<div id="breadcrumb">
				<a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
				<a href="#">Form elements</a>
				<a href="#" class="current">Validation</a>
			</div>
			<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
						<div class="widget-box">
							<div class="widget-title">
								<span class="icon">
									<i class="icon-align-justify"></i>									
								</span>
								<h5>Rest of elements...</h5>
							</div>
							<div class="widget-content nopadding">
								<form class="form-horizontal" method="post" action="addContact" name="basic_validate" id="basic_validate" novalidate="novalidate" />
                                    <h5>基本信息</h5><hr>
                                    <div class="control-group">
                                        <label class="control-label">姓名：</label>
                                        <div class="controls">
                                            <input type="text" name="name" class="redStar" value=${contact.name}> <span id="nameSpan" style="color:red;">*</span>
                                        </div>
                                    </div>
                                    
                                    <div class="control-group">
										<label class="control-label">性别：</label>
										<div class="controls">
											<label><input type="radio" name="sex" value="男" id="boy"/> 男</label>
											<label><input type="radio" name="sex" value="女" id="girl"/> 女</label>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">职务：</label>
										<div class="controls">
											<input type="text" name="job" class="redStar" value=${contact.job}> <span id="jobSpan" style="color:red;">*</span>
										</div>
									</div>
									<div class="control-group">
                                        <label class="control-label">手机：</label>
                                        <div class="controls">
                                            <input type="text" name="phone" class="redStar" value=${contact.phone}> <span id="phoneSpan" style="color:red">*</span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">电话：</label>
                                        <div class="controls">
                                            <input type="text" name="tel" class="redStar" value=${contact.tel}> <span id="telSpan" style="color:red">*</span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">邮箱：</label>
                                        <div class="controls">
                                            <input type="text" name="email" class="redStar" value=${contact.email}> <span id="emailSpan" style="color:red">*</span>
                                        </div>
                                    </div>
                                    <div class="control-group">
										<label class="control-label">QQ：</label>
										<div class="controls">
											<input type="text" name="qq" value=${contact.qq}>
										</div>
									</div>
                                    <div class="control-group">
										<label class="control-label">微信：</label>
										<div class="controls">
											<input type="text" name="wechat" value=${contact.wechat}>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">地址：</label>
										<div class="controls">
											<input type="text" name="address" value=${contact.address}>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">重要等级：</label>
										<div class="controls">
											<select name="important">
												<option />一般
												<option />重要
												<option />很重要
												<option />非常重要
											</select>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">跟进状态：</label>
										<div class="controls">
											<select name="busStatus">
												<option />未处理
												<option />无效
												<option />有效
												<option />放弃
											</select>
										</div>
									</div>
									<div class="control-group">
                                        <label class="control-label">经办人：</label>
                                        <div class="controls">
                                        	<select name="operatorName" >
                                            <#list staffList as staff>
											<option value="${staff.id }">${staff.name }</option>
											</#list>
											</select>
                                            <input type="hidden" name="contactIdStr" value=${contact.id}>
                                        </div>
                                    </div>
									<div class="control-group">
										<label class="control-label">信息来源：</label>
										<div class="controls">
											<textarea name="infoSource"></textarea>
										</div>
									</div>
									<div class="control-group">
                                        <label class="control-label">创建时间：</label>
                                        <div class="controls">
                                            <input type="text" name="createDateStr" data-date="12-02-2012" data-date-format="dd-mm-yyyy" class="datepicker" value=${contact.createDateStr}>
                                        </div>
                                    </div>  
									<div class="control-group">
										<label class="control-label">备注：</label>
										<div class="controls">
											<textarea name="remark"></textarea>
										</div>
									</div> 
                                    <div class="form-actions">
                                        <input type="button" id="submitbt" value="提交" class="btn btn-primary"/>
                                    </div>
                                </form>
                                
							</div>
						</div>			
					</div>
				</div>
				<div class="row-fluid">
					<div id="footer" class="span12">
						2012 &copy; Unicorn Admin. Brought to you by <a href="https://wrapbootstrap.com/user/diablo9983">diablo9983</a>
					</div>
				</div>
			</div>
		</div>
		
		
            
            <script src="/static/js/jquery.min.js"></script>
            <script src="/static/js/jquery.ui.custom.js"></script>
            <script src="/static/js/bootstrap.min.js"></script>
            <script src="/static/js/bootstrap-colorpicker.js"></script>
            <script src="/static/js/bootstrap-datepicker.js"></script>
            <script src="/static/js/jquery.uniform.js"></script>
            <script src="/static/js/select2.min.js"></script>
            <script src="/static/js/unicorn.js"></script>
            <script src="/static/js/unicorn.form_common.js"></script>
	</body>
</html>
